package com.gee.spring.boot.starter.opengemini.core.query.segment;

import java.time.Duration;

import static com.gee.spring.boot.starter.opengemini.core.constant.StrConstant.LEFT_BRACKET;
import static com.gee.spring.boot.starter.opengemini.core.constant.StrConstant.RIGHT_BRACKET;


/**
 * @author gepengjun
 * @since 2024/4/28 16:03
 */
public class GroupByTimeSegment extends GroupBySegment{

    private final Duration duration;

    public GroupByTimeSegment(String columnName, Duration duration) {
        super(columnName);
        this.duration = duration;
    }

    @Override
    public String getSqlSegment() {
        return "time" + LEFT_BRACKET + duration.toNanos() + "ns" + RIGHT_BRACKET;
    }
}
